#include "scrollbox.hpp"

#include "sdlutil.hpp"


ScrollBox::ScrollBox(IElement* parent, SDL_Surface* surf)
	:IElement(parent, surf)
	,vertScroll_(this, surf, Vertical)
	,horScroll_(this, surf, Horizontal)
{
	AddChild(&vertScroll_);
	AddChild(&horScroll_);

	vertScroll_.SetLength(300);
	horScroll_.SetLength(300);
}


ScrollBox::~ScrollBox()
{


}

void ScrollBox::update()
{

}

void ScrollBox::render(int x, int y)
{
	int xl = position_.Get(0);
	int yl = position_.Get(1);
	int wl = size_.Get(0);
	int hl = size_.Get(1);

	draw_rect(surface_, xl, yl,  wl, hl, 0x0000ff00,false);
}

bool ScrollBox::mouseUp(int x, int y, Uint8 button)
{
	return true;
}

bool ScrollBox::mouseDown(int x, int y, Uint8 button)
{
	return true;
}

void ScrollBox::onResize()
{
	int x = position_.Get(0);
	int y = position_.Get(1);
	int w = size_.Get(0);
	int h = size_.Get(1);
	vertScroll_.SetPosition(x+w-15, y);
	vertScroll_.SetSize(15, h-15);

	horScroll_.SetPosition(x, y+h-15);
	horScroll_.SetSize(w-15, 15);
}
void ScrollBox::onMove()
{

}